﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration.Configuration;
using System.Linq;
using System.Web;
using WebGrease.Css.Extensions;

namespace QAS.Nekorama.Common
{
    public static class Helper
    {
        public static User GetUserInfo(int id)
        {
            User result = null;
            using (var db = new Entities())
            {
                result = db.Users.SingleOrDefault(u => u.UserID == id);
            }

            return result;

        }

        public static IList<Comment> GetComments(int id, char c)
        {
            var commentlist = new List<Comment>();
            using (var db = new Entities())
            {

                commentlist = c == 'q'
                    ? (from comment in db.Comments
                       where comment.AnswerID == id && comment.QuestionID == null
                       select comment).ToList()
                    : (from comment in db.Comments
                       where comment.QuestionID == id && comment.AnswerID == null
                       select comment).ToList();




            }
            return commentlist;

        }
    }
}